// 引入JSEncrypt文件
import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

//公钥
const publicKey = `MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqzrvmYlNKy4H47Q2cjgzzpaLHqTc/CcNyD/uqgbmsTGZmn6kjKvWrEqNQc9fCMuWm7LRMgNX38kGriI3lYc6+1cVmejYrrvzAOHbEAbx1UxPAWpUvIUL6jyDdQ6cGQo/zaKbC4zk9ORePd1vsZsiOJb4LOIIwoQSv67fvXKQp+80QLJWJwG5i+S5/+mLgf6znxgPVOslINF5m5ne8GZI2wC6hQJL1+eUEuu96mPYDOzCqsAswED5H84NbFj013lAZE38tL/1Cmh9sU48gyQVNYpe9RRe7kuO4IBhSFh1kJcw4uiFKsi+aUqLZqjXWGw79CzFiB6ax6rbafdF4IS/pQIDAQAB`

// 加密方法
const RSAencrypt = (pas) => {
	// 实例化jsEncrypt对象
	let encryptor = new JSEncrypt()
	// 设置公钥
	encryptor.setPublicKey(publicKey)
	return encryptor.encrypt(pas)
}

//解密方法
const RSAdencrypt = (pas) => {
	//实例化jsEncrypt对象
	let decrypt = new JSEncrypt()
	//设置私钥
	decrypt.setPrivateKey(privateKey)
	return decrypt.decrypt(pas)
}

// 进行抛出 注意这里是抛出 而非默认抛出
export { RSAencrypt, RSAdencrypt }
